package acwing._1_1AlgorithmBasic._3SearchGraph;
/**
 * @Project : AlgorithmLearning
 * @Package : ACWing._1_1AlgorithmBasic._3SearchGraph
 * @File : Q0861.java
 * @Author : WangRuoyu
 * @Date : 2023/4/3 16:19
 */

import java.io.*;
import java.util.Arrays;

public class Q0861 {

    static void add(int a, int b, int[] h, int[] e, int[] next, int idx) {
        e[idx] = b;
        next[idx] = h[a];
        h[a] = idx;
    }

    static boolean find(int u, int[] h, int[] e, int[] next, int[] match, boolean[] st) {
        for (int i = h[u]; i != -1; i = next[i]) {
            int j = e[i];
            if (!st[j]) {
                st[j] = true;
                if (match[j] == 0 || find(match[j], h, e, next, match, st)) {
                    match[j] = u;
                    return true;
                }
            }
        }
        return false;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] words = br.readLine().split(" ");

        int n1 = Integer.parseInt(words[0]);
        int n2 = Integer.parseInt(words[1]);
        int m = Integer.parseInt(words[2]);
        int n = Math.max(n1, n2);

        int[] h = new int[n + 1];
        int[] e = new int[2 * m + 10];
        int[] next = new int[2 * m + 10];
        int[] match = new int[n + 1];
        boolean[] st = new boolean[n + 1];
        int idx = 0;
        Arrays.fill(h, -1);

        for (int i = 0; i < m; ++i) {
            words = br.readLine().split(" ");
            int a = Integer.parseInt(words[0]);
            int b = Integer.parseInt(words[1]);
            add(a, b, h, e, next, idx);
            idx++;
        }

        int res = 0;
        for (int i = 1; i <= n1; ++i) {
            Arrays.fill(st, false);
            if (find(i, h, e, next, match, st)) res++;
        }
        System.out.println(res);
    }
}

